<?php

namespace app\model;

use think\Model;

class GoodsTimeDiscount extends Model
{

    protected $connection = 'mysql';

    protected $pk = 'id';

    protected $name = 'goods_time_discount';


    public static function getTimeDiscount($goodsid)
    {
        $timediscount = GoodsTimeDiscount::where(['goods_id' => $goodsid])->select()->toArray();

        $ymd = time_ymd(time());

        if ($timediscount) {
            foreach ($timediscount as &$vo) {
                $vo['begin_time'] = strtotime($ymd . ' ' . $vo['begin_time']);
                $vo['end_time'] = strtotime($ymd . ' ' . $vo['end_time']);
            }
        }
        return $timediscount;
    }
}
